import { createRouter, createWebHistory } from "vue-router";
import UserLayout from "@/pages/layouts/UserLayout.vue";

export const routes = [
  {
    path: "/",
    redirect: "/index",
  },
  {
    path: "/login",
    component: () => import("@/pages/login/index.vue"),
  },
  {
    name: "index",
    path: "/index",
    component: UserLayout,
    redirect: "/lightManage",
    children: [
      {
        name: "somo",
        path: "/somo",
        redirect: "/lightManage",
        children: [
          {
            name: "lightManage",
            path: "/lightManage",
            component: () => import("../pages/LightManage.vue"),
          },
          {
            name: "commentManage",
            path: "/commentManage",
            component: () => import("../pages/commentManage/index.vue"),
          },
        ],
      },
      {
        name: "vehicleManage",
        path: "/vehicleManage",
        redirect: "/carStatus",
        children: [
          {
            name: "carStatus",
            path: "/carStatus",
            component: () => import("../pages/CarStatus.vue"),
          },
          {
            name: "carInfo",
            path: "/carInfo",
            component: () => import("../pages/CarInfo.vue"),
          },
          {
            name: "checkManage",
            path: "/checkManage",
            component: () => import("../pages/CheckManage.vue"),
          },
        ],
      },
      {
        name: "system",
        path: "/system",
        redirect: "/userManage",
        children: [
          {
            name: "userManage",
            path: "/userManage",
            component: () => import("../pages/system/userManage/index.vue"),
          },
          {
            name: "roleManage",
            path: "/roleManage",
            component: () => import("../pages/system/roleManage/index.vue"),
          },
        ],
      },
    ],
  },
];
const router = createRouter({
  scrollBehavior: () => ({ left: 0, top: 0 }),
  history: createWebHistory(),
  routes,
});
router.beforeEach((to, from, next) => {
  next();
});
export default router;
